package com.sgcc.fj.pmos.e_fj_home.presenter;

import com.alibaba.android.arouter.utils.TextUtils;
import com.blankj.utilcode.util.ToastUtils;
import com.sgcc.fj.pmos.common.base.BasePresenter;
import com.sgcc.fj.pmos.common.http.HttpInterConst;
import com.sgcc.fj.pmos.common.http.HttpRequestUtils;
import com.sgcc.fj.pmos.common.http.MvpNetCallback;
import com.sgcc.fj.pmos.common.utils.ListPageUtil;
import com.sgcc.fj.pmos.e_fj_home.bean.DCJZXXBean;
import com.sgcc.fj.pmos.e_fj_home.bean.IformenCodeBean;
import com.sgcc.fj.pmos.e_fj_home.bean.SDRYCLBean;
import com.sgcc.fj.pmos.e_fj_home.contract.DCJZXXContract;
import com.sgcc.fj.pmos.e_fj_home.contract.SDRYCLContract;

import java.util.HashMap;
import java.util.Map;

import okhttp3.Call;

public class SDRYCLPresenter extends BasePresenter<SDRYCLContract.View>
        implements SDRYCLContract.Presenter {
    @Override
    public void getData( String applyId) {
        Map<String, Object> data = new HashMap<>();
        data.put("applyId", applyId);
        HttpRequestUtils.getInstance().request(data, HttpInterConst.INFORMATION_DISCLOSURE_GETSDBYAPPLYID, new MvpNetCallback<SDRYCLBean>(getView(), true) {
            @Override
            public void onError(Call call, Exception e, int id) {
                super.onError(call, e, id);
                if (!isViewAttached()) {
                    return;
                }
                getView().getDataFailed();
            }

            @Override
            public void onResponse(SDRYCLBean response, int id) {
                super.onResponse(response, id);
                if (!isViewAttached()) {
                    return;
                }
                if (response != null) {
                    if ("0".equals(response.getStatus())) {
                        if (response.getData() != null) {
                            getView().getDataSuccess(response);
                        }
                    } else {
                        if (!TextUtils.isEmpty(response.getMessage())) {
                            ToastUtils.showShort(response.getMessage());
                        }
                    }
                }
            }
        });
    }
}
